#include<iostream>
#include<string.h>
using namespace std;
typedef struct node{
	char data;
	struct node *lchild;
	struct node *rchild;
}BTNode;
typedef struct node *BTree;
 BTree createBT(char *pre,char *in,int n);
int GetHeight( BTree BT );

int main()
{
	BTree BT;
	int n,m;
	cin>>n;
	char s1[n],s2[n];
	cin>>s1>>s2;
	BT=createBT(s1,s2,n);
	m=GetHeight(BT);
	cout<<m;
	return 0;
 } 
 BTree createBT(char *pre,char *in,int n)
 {
 	BTree b;
 	char *p;
 	int k;
 	if(n<=0)
 	return NULL;
 	b=new BTNode;
 	b->data=*pre;
 	for(p=in;p<n+in;p++)
 	if(*p==*pre)
 	break;
 	k=p-in;
 	b->lchild=createBT(pre+1,in,k);
 	b->rchild=createBT(pre+k+1,p+1,n-k-1);
 	return b;
 }
 int GetHeight( BTree BT )
{
	int count1=0,count2=0;
	if(BT==NULL)
	return (0);
	else{
    count1=GetHeight(BT->lchild);
    count2=GetHeight(BT->rchild);
    return (count1>count2)?(count1+1):(count2+1);
		}
} 
